<?php
namespace app\home\controller;

use app\BaseController;
use app\home\model\Supply;
use app\home\model\SupplyImg;
use app\home\model\News as ModelNews;
use think\facade\View;

class Spd extends BaseController
{
    public function index()
    {
        $supply = Supply::find($_GET['page']);
        if($supply == null){
            abort(404);
            return;
        }
        $imgs = SupplyImg::where(['provid_id'=>$_GET['page']])->select();
        $s_desc['content'] = trim(strip_tags($supply['detail_text']));
        $s_desc['len'] = mb_strlen($s_desc['content']);
        $news_hot = ModelNews::getByOrder('hot_order_desc', 10);
        $news_hot1 = [];
        $news_hot2 = [];
        foreach ($news_hot as $key => $n_h) {
            if($key < 2){
                array_push($news_hot1, $n_h);
            }else{
                array_push($news_hot2, $n_h);
            }
        }
        View::assign('news_hot1', $news_hot1);
        View::assign('news_hot2', $news_hot2);
        View::assign('s_img', $imgs);
        View::assign('s', $supply);
        View::assign('s_desc', $s_desc);
        return View::fetch('spd:index');
    }
}
